exports = module.exports = server => {
	server.group({
		prefix: '/api'
	}, group => {
		group.group({
			prefix: '/miniprogram'
		}, router => {
			router.post('/login', 'miniprogram/UserController@login');

			router.get('/home', (app) => {
				app.json({
					err_code: 2
				})
			});

			router.post('/car', 'miniprogram/CarController@index');
			router.post('/car/info', 'miniprogram/CarController@info');

			router.post('/doc/category', 'miniprogram/DocController@category');
			router.post('/doc', 'miniprogram/DocController@index');

			router.post('/dictionary', 'miniprogram/DictionaryController@index');

			router.post('/article', 'miniprogram/ArticleController@index');
			router.post('/article/latest', 'miniprogram/ArticleController@latest');
			router.post('/article/promotion', 'miniprogram/ArticleController@promotion');
			router.post('/article/info', 'miniprogram/ArticleController@info');

			router.post('/station', 'miniprogram/StationController@index');

			router.post('/util/upload', 'miniprogram/UtilController@upload');

			router.post('/region/cascader', 'miniprogram/RegionController@cascader');
		});

		group.group({
			prefix: '/miniprogram',
			middleware: ['app', 'json', 'jwt'],
		}, router => {
			router.post('/portal/profile', 'miniprogram/UserController@profile');
			router.post('/profile/save', 'miniprogram/UserController@save');

			router.post('/user/tree', 'miniprogram/UserController@tree');
			router.post('/user/remark', 'miniprogram/UserController@remark');

			router.post('/user/promoter', 'miniprogram/UserController@promoter');

			router.post('/order', 'miniprogram/OrderController@index');
			router.post('/order/info', 'miniprogram/OrderController@info');
			router.post('/order/save', 'miniprogram/OrderController@save');
			router.post('/order/delete', 'miniprogram/OrderController@delete');
			router.post('/order/confirm', 'miniprogram/OrderController@confirm');
			router.post('/order/unipay', 'miniprogram/OrderController@unipay');

			router.post('/journal', 'miniprogram/JournalController@index');
			router.post('/withdrawal', 'miniprogram/WithdrawalController@index');
			router.post('/withdrawal/apply', 'miniprogram/WithdrawalController@apply');
		});
	});


	server.group({
		//middleware: ['app', 'json', 'jwt'],
		prefix: '/api',
		//优先级
		priority: 100
	}, group => {
		group.post('/login', 'UserController@login');

		group.get('/debug', 'DebugController@index');
		group.get('/config', 'ConfigController@index');

		group.group({
			prefix: '/wxpay/callback'
		}, router => {
			router.post('/notify', 'miniprogram/OrderController@wxpayNotify');
			router.post('/refund/notify', 'miniprogram/OrderController@wxpayRefundNotify');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/util'
		}, router => {
			router.post('/oss', 'UtilController@oss');
			router.post('/upload', 'UtilController@upload');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/user'
		}, router => {
			router.post('/profile', 'UserController@profile');
			router.post('/password', 'UserController@password');

			router.post('/', 'UserController@index');
			router.post('/info', 'UserController@info');
			router.post('/delete', 'UserController@delete');
			router.post('/save', 'UserController@save');

			router.post('/promoter', 'UserController@promoter');
			router.post('/promoter/delete', 'UserController@deletePromoter');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/region'
		}, router => {
			router.post('/', 'RegionController@index');
			router.post('/cascader', 'RegionController@cascader');
			router.post('/save', 'RegionController@save');
			router.post('/delete', 'RegionController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/config'
		}, router => {
			router.post('/', 'ConfigController@index');
			router.post('/save', 'ConfigController@save');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/industry'
		}, router => {
			router.post('/', 'IndustryController@index');
			router.post('/cascader', 'IndustryController@cascader');
			router.post('/save', 'IndustryController@save');
			router.post('/delete', 'IndustryController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/dictionary'
		}, router => {
			router.post('/', 'DictionaryController@index');
			router.post('/info', 'DictionaryController@info');
			router.post('/save', 'DictionaryController@save');
			router.post('/delete', 'DictionaryController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/article'
		}, router => {
			router.post('/', 'ArticleController@index');
			router.post('/info', 'ArticleController@info');
			router.post('/save', 'ArticleController@save');
			router.post('/delete', 'ArticleController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/doc'
		}, router => {
			router.post('/', 'DocController@index');
			router.post('/info', 'DocController@info');
			router.post('/save', 'DocController@save');
			router.post('/delete', 'DocController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/school'
		}, router => {
			router.post('/', 'SchoolController@index');
			router.post('/info', 'SchoolController@info');
			router.post('/save', 'SchoolController@save');
			router.post('/delete', 'SchoolController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/station'
		}, router => {
			router.post('/', 'StationController@index');
			router.post('/info', 'StationController@info');
			router.post('/save', 'StationController@save');
			router.post('/delete', 'StationController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/role'
		}, router => {
			router.post('/', 'RoleController@index');
			router.post('/save', 'RoleController@save');
			router.post('/delete', 'RoleController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/module'
		}, router => {
			router.post('/', 'ModuleController@index');
			router.post('/tree', 'ModuleController@tree');
			router.post('/save', 'ModuleController@save');
			router.post('/delete', 'ModuleController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/car'
		}, router => {
			router.post('/', 'CarController@index');
			router.post('/info', 'CarController@info');
			router.post('/save', 'CarController@save');
			router.post('/delete', 'CarController@delete');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/order'
		}, router => {
			router.post('/', 'OrderController@index');
			router.post('/info', 'OrderController@info');
			router.post('/save', 'OrderController@save');
			router.post('/delete', 'OrderController@delete');
			router.post('/certificate/url', 'OrderController@certificateUrl');
		});

		group.group({
			middleware: ['jwt'],
			prefix: '/withdrawal'
		}, router => {
			router.post('/', 'WithdrawalController@index');
			router.post('/save', 'WithdrawalController@save');
		});
	})
};
